package cn.xabad.commons.tools;// +----------------------------------------------------------------------

import android.content.Context;
import android.os.Environment;

import java.io.File;

// | Project:   boxfish-android-commons
// +----------------------------------------------------------------------
// | CreateTime: 15/12/1  上午11:11
// +----------------------------------------------------------------------
// | Author:     xab(xab@xabad.cn)
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
public class PathUtils {
    private static PathUtils ourInstance = new PathUtils();
    private static File storageDir = null;

    public static PathUtils getInstance() {
        return ourInstance;
    }

    private PathUtils() {
    }


    public  File generatePath(String pathPrefix, String module, Context var2) {
        String var3 = null;
        if (StringU.isNotEmpty(pathPrefix)) {
            var3 = pathPrefix + "/" + module + "/";
        } else {
            var3 = pathPrefix + "/" + module + "/";
        }
        File file = new File(getStorageDir(var2), var3);
        try {
            FileU.forceMkdir(file);
        } catch (Exception e) {
        }
        return file;
    }

    private static File getStorageDir(Context var0) {
        if (storageDir == null) {
            if (EnvironmentU.isExitsSdcard()) {
                File var1 = Environment.getExternalStorageDirectory();
                if (var1.exists()) {
                    return var1;
                }
            }
            storageDir = var0.getDir("Boxfish", Context.MODE_PRIVATE);
        }
        return storageDir;
    }
}
